<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>  
</head>
<body>
    <div id="app"></div>

    <script type="text/babel">
        const  courses =[
            {id:1,name:'react'},
            {id:2,name:'adad'},
            {id:3,name:'xxxx'},
            {id:4,name:'dklhkhk'}
        ]

        // 根据数据的数组生成标签的数组
        const lis = courses.map(courses => <li key={courses.id}>{courses.name}</li>)
        const vDom = (
            <div>
                <h2>前端框架列表</h2>
                <ul>
                    {
                        
                        // 根据数据的数组生成标签的数组
                        lis
                    }    
                </ul>
            </div>
        )

        /* 错误：warning：Each child in a list should have a unique 'key' prop

        React要求列表中的每个元素都需要有个唯一的key值 ==> 内部优化
        key值尽量用id值，不要用下标 => 后面会讲
        */

        // 渲染虚拟DOM
        ReactDOM.render(vDom,document.getElementById('app'))
    </script>
</body>
</html>